package com.hackerrank.challenges.chocolatefeast;

import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int T = in.nextInt();
		for(int t = 0; t < T; t++) {
			int N = in.nextInt(), C = in.nextInt(), M = in.nextInt(), nc = N / C, cc = nc;
			while(cc >= M) {
				int anc = cc / M;
				cc = cc % M + anc;
				nc += anc;
			}
			System.out.println(nc);
		}
	}
}
